package Utils;

import com.mongodb.BasicDBObject;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.UpdateOptions;
import org.bson.Document;

import java.util.Map;

public class DbTools {
    public static void updateOne(MongoCollection collection, Map doc){
        BasicDBObject query = new BasicDBObject().append("_id", doc.get("_id"));
        BasicDBObject obj = new BasicDBObject("$set", doc);
        collection.updateOne(query, obj, (new UpdateOptions()).upsert(true));
        System.out.println(doc);
    }
}
